<script type="text/javascript" src="{{$LAYOUT_HELPER_URL}}admin/js/ckeditor/ckeditor.js"></script> 
<script type="text/javascript" src="{{$LAYOUT_HELPER_URL}}admin/js/ckfinder/ckfinder.js"></script>  
<link href="{{$LAYOUT_HELPER_URL}}admin/js/jquery-ui/css/ui-lightness/jquery-ui.css" rel="stylesheet" type="text/css"/>
<script src="{{$LAYOUT_HELPER_URL}}admin/js/jquery-ui/js/jquery-ui.js"></script>
<script src="{{$LAYOUT_HELPER_URL}}admin/js/jquery.slug.js"></script>

<script type="text/javascript">
    //<![CDATA[

    jQuery(document).ready(function (){
        CKFinder.setupCKEditor( null, '{{$LAYOUT_HELPER_URL}}admin/js/ckfinder/' );
        jQuery( "#images" ).sortable();
        jQuery( "#images" ).disableSelection();
        //Datepicker
        jQuery( ".date" ).datepicker({
            showAnim        : 'slideDown',
            showButtonPanel : true,
            dateFormat      : '{{$datepickerFormat.js}}'
        });
        var imgId;
        //Display images
        jQuery(".input_image[value!='']").parent().find('div').each( function (index, element){
            jQuery(this).toggle();
        });
        //Make slug
        {{foreach from=$allLangs item=item name=langDiv}}
        jQuery('#title{{$smarty.foreach.langDiv.iteration}}').makeSlug({
            slug: jQuery('#alias{{$smarty.foreach.langDiv.iteration}}')
        });
        {{/foreach}}

        {{if $lid}}
        //Display tabs
        jQuery("ul.content-box-tabs  a").removeClass('current');
        jQuery("#tab_a{{$lid}}").addClass('current');
        
        jQuery("div.tab-content").addClass('hidden');
        jQuery("#tab{{$lid}}").removeClass('hidden');
        {{/if}}
            
    });

    function BrowseServer(id)
    {
    	imgId = id;
    	// You can use the "CKFinder" class to render CKFinder in a page:
    	var finder = new CKFinder();
    	finder.basePath = '{{$LAYOUT_HELPER_URL}}admin/js/ckfinder/';	// The path for the installation of CKFinder (default = "/ckfinder/").
    	finder.selectActionFunction = SetFileField;
    	finder.popup();

    	// It can also be done in a single line, calling the "static"
    	// Popup( basePath, width, height, selectFunction ) function:
    	// CKFinder.Popup( '../../', null, null, SetFileField ) ;
    	//
    	// The "Popup" function can also accept an object as the only argument.
    	// CKFinder.Popup( { BasePath : '../../', selectActionFunction : SetFileField } ) ;
    }

    // This is a sample function which is called when a file is selected in CKFinder.
    function SetFileField( fileUrl )
    {
    	//document.getElementById( 'xFilePath' ).value = fileUrl;
    //	document.getElementById( 'chooseImage_img' + imgId ).src = fileUrl;
        document.getElementById( 'xFilePath' + imgId).value = fileUrl;
      //  document.getElementById( 'chooseImage_div' + imgId).style.display = '';
       // document.getElementById( 'chooseImage_noImage_div' + imgId ).style.display = 'none';
        
    }
    function clearImage(imgId)
    {
        document.getElementById( 'xFilePath' + imgId).value = '';
    }

    function addMoreFile()
    {
        jQuery("ul#files > li.hidden").filter(":first").removeClass('hidden');
    }
    
</script>
<style type="text/css">
    #files { list-style-type: none; margin: 0; padding: 0;}
   #files li { margin: 10px; float: left; text-align: center;  height: 20px;}
</style>


       
            <div class="content-box"><!-- Start Content Box -->
                
                <div class="content-box-header">
                    
                    <h3>Edit Demo</h3>
                    
                    <ul class="content-box-tabs">
                        {{if $fullPermisison}}<li><a href="#tab0" class="default-tab">General</a></li>{{/if}}
                        {{foreach from=$allLangs item=item index=index name=langTab}}
                        <li><a {{if !$fullPermisison && $smarty.foreach.langTab.first}}class="default-tab"{{/if}} href="#tab{{$item.lang_id}}" style="padding-bottom: 4px;"><image style="vertical-align:middle;" src="{{$BASE_URL}}{{$item.lang_image}}"> {{$item.name}}</a></li>
                        {{/foreach}}
                    </ul>
                    
                    <div class="clear"></div>
                    
                </div> <!-- End .content-box-header -->
                
                <div class="content-box-content">
                
                    <form action="" method="post">
                    
                    <!-- GENERAL -->
                    <div class="tab-content  id="tab0">
                    
                        <!-- ERROR -->
                        {{if $errors|@count > 0}}
                        <div class="notification error png_bg">
                            <a href="#" class="close"><img src="{{$LAYOUT_HELPER_URL}}admin/images/icons/cross_grey_small.png" title="Close this notification" alt="close" /></a>
                            <div>
                                {{if $errors.main}}
                                    Error: {{$errors.main}}
                                {{else}}
                                    Error: Please check following information again
                                {{/if}} 
                                                                       
                            </div>
                        </div>
                        {{/if}}
                            
                            <fieldset> <!-- Set class to "column-left" or "column-right" on fieldsets to divide the form into columns -->
                                
                                
                                <p>
                                        <label>Title</label>
                                        <input class="text-input large-input" type="text"  name="data[title]" value="{{$data.title}}" />
                                    </p>
                                <p>
                                
                                 <p>
                                    <label>Description</label>
									<textarea class="text-input textarea" id="textarea" name="data[description]" cols="79" rows="5">{{$data.description}}</textarea>
                                        
                                </p>
                                <p>
                                    <label>Subject<span class="red">*</span></label>              
                                    <select name="data[subject_id]" class="small-input" style="width:376px">
                                    {{foreach from=$allCats item=item}}
                                        <option value="{{$item.content_category_id}}" {{if $data.subject_id == $item.content_category_id}}selected="selected"{{/if}}>{{$item.name}}</option>
                                    {{/foreach}}
                                    </select> 
                                </p>
                               
                               
                                          
                              
                                
         <!-- file -->   
                                    
                                <h4>File: </h4>  
                              
                                
         <!-- END file -->    


                                
                                <p><a href="javascript:addMoreFile()">+ Add more files</a></p> 
                                <ul id="files">
                                    {{foreach from=$data.files item=item key=i name=images }}
                                     <li {{if $i >=2 && null == $item}}class="hidden"{{/if}}>
                                    
                                            <input class="text-input" id="xFilePath{{$i}}" value="{{if $item}}{{$BASE_URL}}{{$item}}{{/if}}" name="data[file][]" type="text" size="60" />
												<input type="button" class="button" onclick="BrowseServer({{$i}});" value="Browse Server" />
												<a href="javascript:clearImage({{$i}});">Delete</a>
                                    </li>
                                    {{/foreach}}
                                </ul>
								
                                
                                <br style="clear: both;"/>
                                
                                
                                <br/>
                                    <input class="button submit" type="button" value="Save" />
                                </p>
                                
                            </fieldset>
                            
                            
                            <div class="clear"></div><!-- End .clear -->
                            
                    </div>  <!-- End GENERAL --> 
                    
                    
                   
                                
                        
                   
                    
                  </form>
                  
                </div> <!-- End .content-box-content -->
                
            </div> <!-- End .content-box -->
            
            
            <div class="clear"></div>

